package week10;

import java.util.Scanner;


class IllegalNameException extends RuntimeException{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public IllegalNameException(String str) {
		super(str);
	}
}
class IllegalScoreException extends Exception{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public IllegalScoreException (String str) {
		super(str);
	}
}
class Student{
	private String name;
	private int score;
	
	public String getName() {
		return name;
	}
	public void setName(String name) throws IllegalNameException{
		if(Character.isDigit(name.toCharArray()[0]))
			throw new IllegalNameException("the first char of name must not be digit, name="+name);
		this.name = name;
	}
	public int getScore() {
		return score;
	}
	public void setScore(int score) {
		this.score = score;
	}

	public String toString() {
		return "Student [name=" + name + ", score=" + score + "]";
	}
	
	public int addScore(int score) throws IllegalScoreException {
		if(score<0||score>100)
			throw new IllegalScoreException("score out of range, score="+score);
		return this.score=score;
	}
}
public class Main7_4 {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		while(true) {
			String str=in.nextLine();
			try {
				if(str.equals("new")) {
				Student stu=new Student();
				String str1=in.nextLine();
				if(str1.split(" ").length!=2) {
					System.out.println("java.util.NoSuchElementException");
					}
				else {
			    stu.setName(str1.split(" ")[0]);
				stu.addScore(Integer.parseInt(str1.split(" ")[1]));
				System.out.println(stu);
				}
				}
				else {
					in.close();
					System.out.println("scanner closed");
					return ;
					}
			}catch(IllegalNameException e) {
				System.out.println(e);
			    continue;
			}catch(IllegalScoreException e) {
				System.out.println(e);
				continue;
			}catch(Exception e) {
				System.out.println(e);
				continue;
			}
			
		}
	}

}
